package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.hl7.common.*;
import com.sunwayhorizo.health.hl7.datatypes.*;
import com.sunwayhorizo.health.hl7.factories.*;
import com.sunwayhorizo.health.hl7.persistent.*;
import java.io.*;
import javax.persistence.*;
import static com.sunwayhorizo.health.hl7.vocabulary.ActCdSetCode.*;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("ENC")
public class PatientEncounter extends Act implements Serializable
{

    /**
     * 
     */
    protected static final long serialVersionUID = 1L;


    /*
     * public CE AcuityLevelCode; public CE AdmissionReferralSourceCode; public
     * CE DischargeDispositionCode; public PQ LengthOfStayQuantity; public BL
     * PreAdmitTestInd; public SET_CE SpecialAccommodationCode; public SET_CE
     * SpecialCourtesiesCode;
     */

    public PatientEncounter() throws Hl7Exception
    {
    }




    public void setCriticalCode(CE ce)
    {
        setRimCoreActCdSets(ce, CRITICALCODE);
    }

    //获得危重病人
    public CE getCriticalCode()
    {
        return DataTypeUtil.getCE(getRimCoreActCdSets(CRITICALCODE));
    }
    
    public void setSurgeryCode(CE ce)
    {
        setRimCoreActCdSets(ce, SURGERYCODE);
    }

    //获得手术病人
    public CE getSurgeryCode()
    {
        return DataTypeUtil.getCE(getRimCoreActCdSets(SURGERYCODE));
    }
    
    public void setTransfuseCode(CE ce)
    {
        setRimCoreActCdSets(ce, TRANSFUSECODE);
    }

    //获得输血病人
    public CE getTransfuseCode()
    {
        return DataTypeUtil.getCE(getRimCoreActCdSets(TRANSFUSECODE));
    }


    public void setAcuityLevelCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PEACUITYLEVELCDSETCODE);
        }
        else
        {
            this.setPeAcuityLevelCodeEtsId(ce.code().toString());
        }
    }


    public CE getAcuityLevelCode() throws Hl7Exception
    {
        if (this.getPeAcuityLevelCodeEtsId().equals(PEACUITYLEVELCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeAcuityLevelCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeAcuityLevelCodeEtsId());
        return null;
    }


    public void setAdmissionReferralSourceCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PEADMISSIONREFSRCCDSETCODE);
        }
        else
        {
            this.setPeAdmissionRefSrcEtsId(ce.code().toString());
        }
    }


    public CE getAdmissionReferralSourceCode() throws Hl7Exception
    {
        if (this.getPeAdmissionRefSrcEtsId().equals(PEADMISSIONREFSRCCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeAdmissionRefSrcEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeAdmissionRefSrcEtsId());
        return null;
    }


    public void setDischargeDispositionCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PEDISCHGDISPOSITIONCDSETCODE);
        }
        else
        {
            this.setPeDischgDispositionEtsId(ce.code().toString());
        }
    }


    public CE getDischargeDispositionCode() throws Hl7Exception
    {
        if (this.getPeDischgDispositionEtsId().equals(PEDISCHGDISPOSITIONCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeDischgDispositionEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeDischgDispositionEtsId());
        return null;
    }


    public void setLengthOfStayQuantity(PQ LengthOfStayQuantity)
    {
        this.setPeLosQtyTxt(LengthOfStayQuantity.value().literal().toString());
        this.setPeLosQtyUomCode(LengthOfStayQuantity.unit().code().toString());
    }


    public PQ getLengthOfStayQuantity() throws Hl7Exception
    {
        return DataTypeUtil.getPQ(this.getPeLosQtyTxt(), this.getPeLosQtyUomCode());
    }


    public void setPreAdmitTestInd(BL PreAdmitTestInd)
    {
        this.setPePreAdmitTestFlag(PreAdmitTestInd.toString());
    }


    public BL getPreAdmitTestInd() throws Hl7Exception
    {
        return DataTypeUtil.getBL(this.getPePreAdmitTestFlag());
    }


    public void setSpecialArrangementCode(CE SpecialAccommodationCode)
    {
        CE ce = SpecialAccommodationCode;
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PESPECIALARRANGEMENTCDSETCODE);
        }
        else
        {
            this.setPeSpecialArrangementCodeEtsId(ce.code().toString());
        }
    }


    public CE getSpecialArrangementCode() throws Hl7Exception
    {
        if (this.getPeSpecialArrangementCodeEtsId().equals(PESPECIALARRANGEMENTCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeSpecialArrangementCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeSpecialArrangementCodeEtsId());
        return null;
    }


    public void setSpecialCourtesiesCode(CE SpecialCourtesiesCode)
    {
        CE ce = SpecialCourtesiesCode;
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PESPECIALCOURTESIESCDSETCODE);
        }
        else
        {
            this.setPeSpecialCourtesiesCodeEtsId(ce.code().toString());
        }
    }


    public CE getSpecialCourtesiesCode() throws Hl7Exception
    {
        if (this.getPeSpecialCourtesiesCodeEtsId().equals(PESPECIALCOURTESIESCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeSpecialCourtesiesCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeSpecialCourtesiesCodeEtsId());
        return null;
    }


    public void setAdmissionWay(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PEADMISSIONWAYCDSETCODE);
        }
        else
        {
            this.setPeAdmissionWay(ce.code().toString());
        }
    }


    public CE getAdmissionWay() throws Hl7Exception
    {
        if (this.getPeAdmissionWay().equals(PEADMISSIONWAYCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeAdmissionWay().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeAdmissionPurpose());
        return null;
    }


    public void setAdmissionPurpose(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PEADMISSIONPURPOSECDSETCODE);
        }
        else
        {
            this.setPeAdmissionPurpose(ce.code().toString());
        }
    }


    public CE getAdmissionPurpose() throws Hl7Exception
    {
        if (this.getPeAdmissionPurpose().equals(PEADMISSIONPURPOSECDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeAdmissionPurpose().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeAdmissionPurpose());
        return null;
    }


    public void setPeLinkMan(ST linkMan)
    {
        this.setLinkMan(linkMan.toString());
    }


    public ST getPeLinkMan() throws Hl7Exception
    {
        if (StrUtil.isEmpty(this.getLinkMan()))
            return null;
        return DataTypeUtil.getST(this.getLinkMan());
    }


    public void setPeLinkManWay(ST linkManWay)
    {
        this.setLinkManWay(linkManWay.toString());
    }


    public ST getPeLinkManWay() throws Hl7Exception
    {
        if (StrUtil.isEmpty(this.getLinkManWay()))
            return null;
        return DataTypeUtil.getST(this.getLinkManWay());
    }


    public void setPeLinkManRelation(ST linkManRelation)
    {
        this.setLinkManRelation(linkManRelation.toString());
    }


    public ST getPeLinkManRelation() throws Hl7Exception
    {
        if (StrUtil.isEmpty(this.getLinkManRelation()))
            return null;
        return DataTypeUtil.getST(this.getLinkManRelation());
    }


    public void setLeaveHospitalWay(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreActCdSets(ce, PELEAVEHOSPITALWAYCDSETCODE);
        }
        else
        {
            this.setPeLeaveHospitalWay(ce.code().toString());
        }
    }


    public CE getLeaveHospitalWay() throws Hl7Exception
    {
        if (this.getPeLeaveHospitalWay().equals(PELEAVEHOSPITALWAYCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPeLeaveHospitalWay().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getPeLeaveHospitalWay());
        return null;
    }

    // PatientEncounter
    @Column(name = "PE_ACUITY_LEVEL_CODE_ETS_ID")
    protected String peAcuityLevelCodeEtsId = PEACUITYLEVELCDSETCODE.toString();
    @Column(name = "PE_ADMISSION_REF_SRC_ETS_ID")
    protected String peAdmissionRefSrcEtsId = PEADMISSIONREFSRCCDSETCODE.toString();
    @Column(name = "PE_DISCHG_DISPOSITION_ETS_ID")
    protected String peDischgDispositionEtsId = PEDISCHGDISPOSITIONCDSETCODE.toString();
    @Column(name = "PE_LOS_QTY_TXT")
    protected String peLosQtyTxt;
    @Column(name = "PE_LOS_QTY_UOM_CODE")
    protected String peLosQtyUomCode;
    @Column(name = "PE_PRE_ADMIT_TEST_FLAG")
    protected String pePreAdmitTestFlag;
    @Column(name = "PE_SPECIAL_ARRANGE_CODE_ETS_ID")
    protected String peSpecialArrangementCodeEtsId = PESPECIALARRANGEMENTCDSETCODE.toString();
    @Column(name = "PE_SPECIAL_COURTE_CODE_ETS_ID")
    protected String peSpecialCourtesiesCodeEtsId = PESPECIALCOURTESIESCDSETCODE.toString();

    @Column(name = "PE_ADMISSION_WAY")
    protected String peAdmissionWay = PEADMISSIONWAYCDSETCODE.toString();// 入院方式
    @Column(name = "PE_ADMISSION_PURPOSE")
    protected String peAdmissionPurpose = PEADMISSIONPURPOSECDSETCODE.toString(); // 入院目的
    @Column(name = "PE_LINKMAN")
    protected String linkMan; // 联系人
    @Column(name = "PE_LINKMAN_WAY")
    protected String linkManWay; // 联系方式
    @Column(name = "PE_LINKMAN_RELATION")
    protected String linkManRelation;// 联系人关系
    @Column(name = "PE_LEAVEHOSPITAL_WAY")
    protected String peLeaveHospitalWay = PELEAVEHOSPITALWAYCDSETCODE.toString(); // 出院方式


    protected String getPeSpecialArrangementCodeEtsId()
    {
        return peSpecialArrangementCodeEtsId;
    }


    protected void setPeSpecialArrangementCodeEtsId(String peSpecialArrangementCodeEtsId)
    {
        this.peSpecialArrangementCodeEtsId = peSpecialArrangementCodeEtsId;
    }


    protected String getPeSpecialCourtesiesCodeEtsId()
    {
        return peSpecialCourtesiesCodeEtsId;
    }


    protected void setPeSpecialCourtesiesCodeEtsId(String peSpecialCourtesiesCodeEtsId)
    {
        this.peSpecialCourtesiesCodeEtsId = peSpecialCourtesiesCodeEtsId;
    }


    protected String getPeAdmissionWay()
    {
        return peAdmissionWay;
    }


    protected void setPeAdmissionWay(String peAdmissionWay)
    {
        this.peAdmissionWay = peAdmissionWay;
    }


    protected String getPeAdmissionPurpose()
    {
        return peAdmissionPurpose;
    }


    protected void setPeAdmissionPurpose(String peAdmissionPurpose)
    {
        this.peAdmissionPurpose = peAdmissionPurpose;
    }


    protected String getPeLeaveHospitalWay()
    {
        return peLeaveHospitalWay;
    }


    protected void setPeLeaveHospitalWay(String peLeaveHospitalWay)
    {
        this.peLeaveHospitalWay = peLeaveHospitalWay;
    }


    protected String getPeAcuityLevelCodeEtsId()
    {
        return peAcuityLevelCodeEtsId;
    }


    protected void setPeAcuityLevelCodeEtsId(String peAcuityLevelCodeEtsId)
    {
        this.peAcuityLevelCodeEtsId = peAcuityLevelCodeEtsId;
    }


    protected String getPeAdmissionRefSrcEtsId()
    {
        return peAdmissionRefSrcEtsId;
    }


    protected void setPeAdmissionRefSrcEtsId(String peAdmissionRefSrcEtsId)
    {
        this.peAdmissionRefSrcEtsId = peAdmissionRefSrcEtsId;
    }


    protected String getPeDischgDispositionEtsId()
    {
        return peDischgDispositionEtsId;
    }


    protected void setPeDischgDispositionEtsId(String peDischgDispositionEtsId)
    {
        this.peDischgDispositionEtsId = peDischgDispositionEtsId;
    }


    protected String getPeLosQtyTxt()
    {
        return peLosQtyTxt;
    }


    protected void setPeLosQtyTxt(String peLosQtyTxt)
    {
        this.peLosQtyTxt = peLosQtyTxt;
    }


    protected String getPeLosQtyUomCode()
    {
        return peLosQtyUomCode;
    }


    protected void setPeLosQtyUomCode(String peLosQtyUomCode)
    {
        this.peLosQtyUomCode = peLosQtyUomCode;
    }


    protected String getPePreAdmitTestFlag()
    {
        return pePreAdmitTestFlag;
    }


    protected void setPePreAdmitTestFlag(String pePreAdmitTestFlag)
    {
        this.pePreAdmitTestFlag = pePreAdmitTestFlag;
    }


    protected String getLinkMan()
    {
        return linkMan;
    }


    protected void setLinkMan(String linkMan)
    {
        this.linkMan = linkMan;
    }


    protected String getLinkManWay()
    {
        return linkManWay;
    }


    protected void setLinkManWay(String linkManWay)
    {
        this.linkManWay = linkManWay;
    }


    protected void setLinkManRelation(String linkManRelation)
    {
        this.linkManRelation = linkManRelation;
    }


    protected String getLinkManRelation()
    {
        return linkManRelation;
    }


    public void setChargeType(CE chargeType)
    {
        setRimCoreActCdSets(chargeType, PECHARGETYPECODE);
    }


    public CE getChargeType()
    {
        if (getRimCoreActCdSets(PECHARGETYPECODE) == null)
        {
            return null;
        }

        return DataTypeUtil.getCE(getRimCoreActCdSets(PECHARGETYPECODE));
    }

}
